<template>
    <container type="top-header" :show="{header:formShow}" class="g-width100 g-height100" header-style="height:auto;" main-style="padding:0;">
        <Form slot="header" inline
              submit-bus-key="BuildingManageList"
              :form-items="formItems"
              label-width=""
        ></Form>
        <Table slot="main"
               ref="table"
               form-submit-bus-key="BuildingManageList"
               :columns="columns"
               :operations="tableOperations"
               unique-label="name"
               v-on:toolbarSearchClick="formShow = !formShow"
        ></Table>
    </container>
</template>

<script>
    import Container from '../../../../common-util/src/components/page/Container.vue'
    import Form from '../../../../common-util/src/components/page/Form.vue'
    import Table from '../../../../common-util/src/components/page/Table.vue'

    export default {
        components:{
            Form,
            Table,
            Container
        },
        data(){
            return {
                formShow: true,
                formItems:[

                    {
                        field: {
                            name: 'estateId',
                            value: this.$route.query.estateId || null,
                            estateId__label: this.$route.query.estateName || null
                        },
                        element:{
                            label: '楼盘',
                            type: 'selectRemote',
                            selectRemote:{
                                url: this.$baseURL.house + '/house/estate/listPage',
                            },
                        }
                    },
                    {
                        field: {
                            name: 'code'
                        },
                        element:{
                            label: '编号',
                        }
                    },
                    {
                        field: {
                            name: 'name'
                        },
                        element:{
                            label: '名称',
                        }
                    },
                    {
                        field: {
                            name: 'nameAlias'
                        },
                        element:{
                            label: '名称别名',
                        }
                    },

                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'get',
                                    url: this.$baseURL.house + '/house/building/listPage',
                                    label: '查询'
                                },
                                {
                                    action: 'reset',
                                    label: '重置'
                                }
                            ]
                        }
                    }
                ],
                columns:[
                    {
                        prop: 'code',
                        label:'编号'
                    },
                    {
                        prop: 'name',
                        label:'名称'
                    },
                    {
                        prop: 'nameAlias',
                        label:'名称别名'
                    },
                    {
                        prop: 'longitude',
                        label:'经度',
                        showInDetail: true
                    },
                    {
                        prop: 'latitude',
                        label:'纬度',
                        showInDetail: true
                    },
                    {
                        prop: 'belowGroundParkingSpaceNum',
                        label:'地下车位数',
                        showInDetail: true
                    },
                    {
                        prop: 'buildAtTxt',
                        label:'始建于',
                        showInDetail: true
                    },
                    {
                        prop: 'builtAtTxt',
                        label:'建成于',
                        showInDetail: true
                    },
                    {
                        prop: 'developerCompanyName',
                        label:'开发商公司',
                        showInDetail: true
                    },
                    {
                        prop: 'propertyCompanyName',
                        label:'物业公司',
                        showInDetail: true
                    },
                    {
                        prop: 'estateName',
                        label:'楼盘名称'
                    },
                    {
                        prop: 'estatePhaseName',
                        label:'楼盘分期',
                        showInDetail: true
                    },
                    {
                        prop: 'floorNum',
                        label:'总层数'
                    },
                    {
                        prop: 'unitNum',
                        label:'单元数',
                        showInDetail: true
                    },
                    {
                        prop: 'roomNum',
                        label:'总套数',
                        showInDetail: true
                    },
                    {
                        prop: 'presaleEstateLicenceName',
                        label:'预售许可证',
                        showInDetail: true
                    },
                ],
                tableOperations:[
                    {
                        action: 'nav',
                        url:'/building/buildingAdd',
                        label: '添加'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url:'/building/buildingEdit/:id',
                        label: '编辑'
                    },
                    {
                        action: 'detail',
                        disabledOnMissingSelect:true,
                        label: '详情'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/buildingUnitNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.estateId,
                                estateName: row.estateName,
                                buildingId: row.id,
                                buildingName: row.name,
                            }
                        },
                        label: '单元管理'
                    },
                    {
                        action: 'nav',
                        disabledOnMissingSelect:true,
                        url: '/buildingRoomNoCache',
                        routeQuery: (row)=>{
                            return {
                                estateId: row.estateId,
                                estateName: row.estateName,
                                buildingId: row.id,
                                buildingName: row.name,
                            }
                        },
                        label: '房屋管理'
                    },
                    {
                        action: 'delete',
                        url:this.$baseURL.house + '/house/building/:id',
                        disabledOnMissingSelect:true,
                        label:'删除'
                    }
                ]
            }
        }
    }
</script>

<style scoped>

</style>